#!/bin/bash
# If this proxy is called with the --xml parameter then just return the module decriptor XML file,
# otherwise run the associated Matlab script.
# MatlabBridge proxy version: 1.1

MODULE_NAME="Image2Mesh"

if [ "$1" == "--xml" ]; then
  cat $MODULE_NAME.xml
  exit 0
fi

# Make this proxy file location to be the working directory (this is where the .m file is located; in Matlab the current directory will be changed to this directory)
cd "$( dirname "$0" )"

# Forward parameters to the Matlab CLI
if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
  # Linux: use Slicer launcher
  "$SLICER_HOME/NIRFASTSlicer" --launcher-no-splash --launch "$SLICER_MATLAB_COMMANDER_PATH" --call-matlab-function $MODULE_NAME $*
  exit $?
else
  # Mac OS X: there is no launcher, so run the commander directly
  "$SLICER_MATLAB_COMMANDER_PATH" --call-matlab-function $MODULE_NAME $*
  exit $?
fi
